/**
 * 高阶组件实现继承
 * Author: luweijun
 * Date: 2017-3-5
 */

import tool from '../../../../../utils/tool';
import React from 'react';
let Base = (ComponentNeedMix) => class extends React.Component{
    constructor(props) {
        super(props);
    }
    componentWillMount (){
        this.widget = $.extend(true, {}, this.props.widget);
    }
    // 优化刷新
    shouldComponentUpdate (nextProps, nextState){
        var current = this.widget, next = nextProps.widget;
        if (current && next){
            this.widget = $.extend(true, {}, next);
            return !(tool.isObjectEqual(current, next));
        }
        return false;
    }
    render() {
        return (
            <ComponentNeedMix {...this.props} {...this.state} />
        )
    }
}
export default Base;
